<{include file="public/header.html"}>
<link rel="stylesheet" type="text/css" href="/static/default/css/index.css">
<link rel="stylesheet" type="text/css" href="/static/default/css/common.css"/>

<div class="credit-main w1180-con mt20">
    <div class="mb20" style="height: 193px; background: url(/static/default/img/introduce/4.jpg) no-repeat center 0;">
    </div>
    <!--面包屑、导航-->
    <div class="bread-nav">
        <h4 class="task-bread-title f-cb" style="font-size: 14px;">
            <div class="fl"><a href="/">首页</a><span style="margin: 0 8px;">&gt;</span><a href="/task.html">溜溜任务</a></b></div>
            <div class="fr">
                <input type="text" class="input-text" id="keywords" name="keywords" placeholder="请输入关键词">
                <input type="submit" class="input-submit" id="search_task" value="">
            </div>
        </h4>
        <div class="task-nav-list">
            <div class="nav-list f-cb">
                <p class="fl">任务类型：</p>
                <div class="f-cb div-ul type-div">
                    <a href="javascript:void(0);" class="hovering classify colred" data-id="0">全部</a>
                    <a href="javascript:void(0);" class="hovering classify" data-id="1">理财任务</a>
                    <a href="javascript:void(0);" class="hovering classify" data-id="2">注册任务</a>
                    <a href="javascript:void(0);" class="hovering classify" data-id="3">区间理财</a>
                </div>
            </div>
            <div id="classify_l">
                <div class="nav-list f-cb">
                    <p class="fl">理财期限：</p>
                    <div class="f-cb div-ul term-div">
                        <a href="javascript:void(0);" class="hovering classify colred" data-id="0">全部</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="1">0~30天</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="2">30~90天</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="3">90~180天</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="4">180~365天</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="5">365天以上</a>
                    </div>
                </div>
                <div class="nav-list f-cb">
                    <p class="fl">起购金额：</p>
                    <div class="f-cb div-ul amount-div">
                        <a href="javascript:void(0);" class="hovering classify colred" data-id="0">全部</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="1">0-1000元</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="2">1000元-1万</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="3">1万-5万</a>
                        <a href="javascript:void(0);" class="hovering classify" data-id="4">5万以上</a>
                    </div>
                </div>
            </div>
            <div id="classify_o">
                <div class="nav-list f-cb">
                    <p class="fl">标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;签：</p>
                    <div class="f-cb div-ul tags-div">
                        <a href="javascript:void(0);" class="hovering classify colred" data-id="0">全部</a>
                        <{foreach from=$tags item=val}>
                        <a href="javascript:void(0);" class="hovering classify" data-name="<{$val['name']}>"><{$val['name']}></a>
                        <{/foreach}>
                    </div>
                </div>
            </div>

        </div>
    </div>

    <ul class="task-list mt30 f-cb">

    </ul>

</div>
<div class="holder" id="credit_pagination"></div>
<script type="text/javascript">
    $(function () {
        loadCredit(0);
        $('.div-ul a').on('click', function () {
            $(this).addClass('colred').siblings().removeClass('colred');
            $(this).parent().siblings('.nav-all').removeClass('colred');
            loadCredit(0);
        });
        $('#search_task').on('click', function () {
            loadCredit(0);
        });
    });

    function showCreditInfo(ID) {
        var params = {};
        params.id = ID;
        doRequest("/task/info.html", params, false, function (data) {
            $("body").find(".popup-credit,.popup-credit-sign").remove().end().append(data.data);
            layer.msg("余额不足哦！", {icon: 0, time: 1000, offset: 300});
        }, errorCallback);
    }
    function ajaxApply(tid) {
        var params = {};
        params.tid = tid;
        doRequest("/task/ajax_apply.html", params, false, function (data) {
            $("body").find(".popup-credit,.popup-credit-sign").remove().end().append(data.data);
            layer.msg(data.msg, {icon: 0, time: 1000, offset: 300});

            setTimeout(function () {
                window.open(data.link);
            }, 1000);


        }, errorCallback);
    }
    function successLoadCredit(resp) {
        var totalCount = resp.data.totalCount;
        var str = "";
        if (totalCount == 0) {
            str += "<div class='no-card'><b class='icon icon-hasno'></b>没有任务</div>";
        }
        var list = resp.data.list;

        $.each(list, function (index, data) {
            str += data.str;
        });

        //$(".credit-card-list").html(str);
        $(".task-list").html(str);

        creditPage(totalCount, resp.data.pageIndex);
    }
    function loadCredit(pageIndex) {

        var params = {};
        params.type = $(".type-div .colred").attr("data-id");
        params.term = $(".term-div .colred").attr("data-id");
        params.amount = $(".amount-div .colred").attr("data-id");
        params.tags = $(".tags-div .colred").attr("data-name");
        params.keyword = $("#keywords").val();
        params.pageIndex = pageIndex;
        console.log(params);
        doRequest("/task/new_mlist.html", params, false, successLoadCredit, errorCallback);
    }

    function creditPage(total, pageIndex) {
        $("#credit_pagination").pagination(total, { //recordCount在后台定义的一个公有变量，通过从数据库查询记录进行赋值，返回记录的总数
            callback: loadCredit,  //点击分页时，调用的回调函数
            prev_text: '<',  //显示上一页按钮的文本
            next_text: '>',  //显示下一页按钮的文本
            link_to: "javascript:void(0);",
            items_per_page: 12,  //每页显示的项数
            num_display_entries: 6,  //分页插件中间显示的按钮数目
            current_page: pageIndex,  //当前页索引
            num_edge_entries: 2  //分页插件左右两边显示的按钮数目
        });
    }

    /**
     * credit-card detail 弹窗
     * */
    $("body").delegate('.popup-credit-sign .icon-close', 'click', function () {
        $(this).parents('.popup-credit-sign').fadeOut();
        $('.popup-credit').fadeOut();
    });
    $("body").delegate('.popup-credit-sign .tab span', 'click', function () {
        index = $(this).parent().children().index($(this));
        $('.popup-credit-sign .credit-con .credit-txt').eq(index).fadeIn().siblings().hide();
        $(this).addClass('popup-credit-line').siblings().removeClass('popup-credit-line');
    });

</script>

<!--footer-->
<{include file="public/footer.html"}>